/**
 * @Author: zc
 * @Date: 2020-07-07 10:05:36
 * @LastEditors: zc
 * @LastEditTime: 2020-07-07 14:20:17
 */
import { lStorage } from './storage';

class Local {
  update(key: string, value: any) {
    const _val = lStorage.getItem(key);
    if (_val) {
      // 如果已存key先删除，再set
      this.removeItem(key);
    }
    lStorage.setItem(key, value);
  }

  getItem(key: string) {
    return lStorage.getItem(key);
  }

  removeItem(key: string) {
    lStorage.removeItem(key);
  }

  clear() {
    lStorage.clear();
  }
}

export const local = new Local();
